CREATE TABLE [dbo].[MatchingGiftPlan]
(
[MatchingGiftPlanKey] [uniqueidentifier] NOT NULL,
[Name] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[PlanProcedure] [nvarchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[RulesDescription] [nvarchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[OwnerContactKey] [uniqueidentifier] NOT NULL,
[MatchingRatio] [decimal] (12, 4) NOT NULL CONSTRAINT [DF_MatchingGiftPlan_MatchingRatio] DEFAULT ((1)),
[EffectiveDate] [datetime] NULL,
[TerminationDate] [datetime] NULL,
[MatchingGiftPlanTypeKey] [uniqueidentifier] NOT NULL,
[IsPledgeQualified] [bit] NOT NULL CONSTRAINT [DF_MatchingGiftPlan_IsPledgeQualified] DEFAULT ((1)),
[IsGiftQualified] [bit] NOT NULL CONSTRAINT [DF_MatchingGiftPlan_IsGiftQualified] DEFAULT ((1)),
[MatchingGiftContactKey] [uniqueidentifier] NULL,
[CorporateGiftContactKey] [uniqueidentifier] NULL,
[IsAutomatch] [bit] NOT NULL CONSTRAINT [DF_MatchingGiftPlan_IsAutomatch] DEFAULT ((1)),
[MatchingMode] [int] NOT NULL CONSTRAINT [DF_MatchingGiftPlan_MatchingMode] DEFAULT ((0)),
[PreferredMatchingProductKey] [uniqueidentifier] NULL,
[MaximumMatchAmount] [decimal] (18, 4) NULL,
[MaximumMatchPeriod] [int] NULL,
[UpdatedByUserKey] [uniqueidentifier] NOT NULL,
[UpdatedOn] [datetime] NOT NULL,
[AccessKey] [uniqueidentifier] NOT NULL,
[CreatedByUserKey] [uniqueidentifier] NOT NULL,
[CreatedOn] [datetime] NOT NULL,
[SystemEntityKey] [uniqueidentifier] NOT NULL,
[MarkedForDeleteOn] [datetime] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MatchingGiftPlan] ADD CONSTRAINT [PK_MatchingGiftPlan] PRIMARY KEY CLUSTERED ([MatchingGiftPlanKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_MatchingGiftPlan_AccessKey] ON [dbo].[MatchingGiftPlan] ([AccessKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_MatchingGiftPlan_CorporateGiftContactKey] ON [dbo].[MatchingGiftPlan] ([CorporateGiftContactKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_MatchingGiftPlan_CreatedByUserKey] ON [dbo].[MatchingGiftPlan] ([CreatedByUserKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_MatchingGiftPlan_MatchingGiftContactKey] ON [dbo].[MatchingGiftPlan] ([MatchingGiftContactKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_MatchingGiftPlan_MatchingGiftPlanTypeKey] ON [dbo].[MatchingGiftPlan] ([MatchingGiftPlanTypeKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_MatchingGiftPlan_OwnerContactKey] ON [dbo].[MatchingGiftPlan] ([OwnerContactKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_MatchingGiftPlan_SystemEntityKey] ON [dbo].[MatchingGiftPlan] ([SystemEntityKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_MatchingGiftPlan_UpdatedByUserKey] ON [dbo].[MatchingGiftPlan] ([UpdatedByUserKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MatchingGiftPlan] ADD CONSTRAINT [FK_MatchingGiftPlan_AccessMain] FOREIGN KEY ([AccessKey]) REFERENCES [dbo].[AccessMain] ([AccessKey])
GO
ALTER TABLE [dbo].[MatchingGiftPlan] ADD CONSTRAINT [FK_MatchingGiftPlan_ContactMain_CorprateGift] FOREIGN KEY ([CorporateGiftContactKey]) REFERENCES [dbo].[ContactMain] ([ContactKey])
GO
ALTER TABLE [dbo].[MatchingGiftPlan] ADD CONSTRAINT [FK_MatchingGiftPlan_ContactMain_MatchingGift] FOREIGN KEY ([MatchingGiftContactKey]) REFERENCES [dbo].[ContactMain] ([ContactKey])
GO
ALTER TABLE [dbo].[MatchingGiftPlan] ADD CONSTRAINT [FK_MatchingGiftPlan_ContactMain_Owner] FOREIGN KEY ([OwnerContactKey]) REFERENCES [dbo].[ContactMain] ([ContactKey])
GO
ALTER TABLE [dbo].[MatchingGiftPlan] ADD CONSTRAINT [FK_MatchingGiftPlan_MatchingGiftPlanTypeRef] FOREIGN KEY ([MatchingGiftPlanTypeKey]) REFERENCES [dbo].[MatchingGiftPlanTypeRef] ([MatchingGiftPlanTypeKey])
GO
ALTER TABLE [dbo].[MatchingGiftPlan] ADD CONSTRAINT [FK_MatchingGiftPlan_SystemEntity] FOREIGN KEY ([SystemEntityKey]) REFERENCES [dbo].[SystemEntity] ([SystemEntityKey])
GO
ALTER TABLE [dbo].[MatchingGiftPlan] ADD CONSTRAINT [FK_MatchingGiftPlan_UniformRegistry] FOREIGN KEY ([MatchingGiftPlanKey]) REFERENCES [dbo].[UniformRegistry] ([UniformKey])
GO
ALTER TABLE [dbo].[MatchingGiftPlan] ADD CONSTRAINT [FK_MatchingGiftPlan_UserMain_CreatedBy] FOREIGN KEY ([CreatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO
ALTER TABLE [dbo].[MatchingGiftPlan] ADD CONSTRAINT [FK_MatchingGiftPlan_UserMain_UpdatedBy] FOREIGN KEY ([UpdatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO